package cn.exception;


import java.io.File;
import java.io.FilenameFilter;

public class LsDemo{

  public static void main(String[] args) {
    File work = new File("src/day16");
    String ext = ".txt";
    String[] list = work.list(new Filter(ext)); 
    System.out.println("Content in "+ 
        work.getAbsolutePath());
    for (int i = 0; i < list.length; i++) {
      String name = list[i];
      System.out.println(name);
    }
  }
  static class Filter implements FilenameFilter{
    private String ext;
    public Filter(String ext) {
      this.ext = ext;
    }
    public boolean accept(File dir, String name){
      return name.endsWith(ext);
    }
  }

}


